/*
 *显示按键点击的实时时间
 *
*/
#include "formnew_01.h"
#include "ui_formnew_01.h"

Formnew_01 *pmid = NULL;

Formnew_01::Formnew_01(QWidget *parent) :QWidget(parent),ui(new Ui::Formnew_01)
{
    ui->setupUi(this);

//============================ < 新的表格：记录显示其他操作的实时时间 > ========================
    //分配表格固定大小
    //初始0行。后续除非时间事件，再自动续行（登录的时候，会自动创建一行）
    ui->tableWidget->setRowCount(0);
    ui->tableWidget->setColumnCount(2);

    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);

    QStringList header;
    header << "事件" << "时间";
    ui->tableWidget->setHorizontalHeaderLabels(header);

    //设置tablewidget滑杆的宽度
    ui->tableWidget->verticalScrollBar()->setStyleSheet("QScrollBar{background:transparent; width:20px}");

    qDebug() << "Formnew_01【界面】" << endl;

    pmid = this;//既然是mymainwindow.ui中的一个控件，便把堆区空间地址给到类指针pmid，方便另外两个文件中对其操作，因此它在两个文件中作用是作为响应对象存在的

}

Formnew_01::~Formnew_01()
{
    delete ui;
}


//所有从mymainwindow.cpp接收的信号，都由一个槽函数响应
//槽函数再根据传递信号的int参数，对应响应按键时间
void Formnew_01::formnew_01_Receive_the_response(int response_num, QString str)
{
    int curRow  = ui->tableWidget->rowCount();
    //这里会自动在当前行下方添加行
    ui->tableWidget->insertRow(curRow);

    switch (response_num) {
    case 1:
            //插入行不可以错误，否则会无法显示在表格中
            ui->tableWidget->setItem(curRow,0,new QTableWidgetItem("添加行"));
            ui->tableWidget->setItem(curRow,1, new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss")));
            qDebug() << "按下pushButton_04【添加行】时间 ："<<QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss") << endl;
        break;
    case 2:
            ui->tableWidget->setItem(curRow,0,new QTableWidgetItem("删除行"));
            ui->tableWidget->setItem(curRow,1, new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss")));
        break;
    case 5:
            ui->tableWidget->setItem(curRow,0,new QTableWidgetItem("查找指定位置本文"));
            ui->tableWidget->setItem(curRow,1, new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss")));
        break;
    case 6:
            ui->tableWidget->setItem(curRow,0,new QTableWidgetItem("添加、覆盖、修改"));
            ui->tableWidget->setItem(curRow,1, new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss")));
        break;
    case 7:
            ui->tableWidget->setItem(curRow,0,new QTableWidgetItem("删除指定位置文本"));
            ui->tableWidget->setItem(curRow,1, new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss")));
        break;
    case 8:
            ui->tableWidget->setItem(curRow,0,new QTableWidgetItem("隐藏、显示【formnew_01_ui表格】"));
            ui->tableWidget->setItem(curRow,1, new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss")));
        break;
    case 9:
            ui->tableWidget->setItem(curRow,0,new QTableWidgetItem("隐藏【界面1】，打开【界面0】"));
            ui->tableWidget->setItem(curRow,1, new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss")));
        break;
    case 10:
            ui->tableWidget->setItem(curRow,0,new QTableWidgetItem("隐藏【界面0】，打开【界面1】"));
            ui->tableWidget->setItem(curRow,1, new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss")));
        break;
    case 11:
            ui->tableWidget->setItem(curRow,0,new QTableWidgetItem("隐藏【界面1】，打开【界面3】文本编辑界面"));
            ui->tableWidget->setItem(curRow,1, new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss")));
        break;
    case 12:
            ui->tableWidget->setItem(curRow,0,new QTableWidgetItem("隐藏【界面3】，打开【界面1】表格界面"));
            ui->tableWidget->setItem(curRow,1, new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd dddd hh:mm:ss")));
        break;

    default:
        break;
    }
}



